﻿using UnityEngine;
using System.Collections;

public class Position {

    private int _x;
    public int X
    {
        get { return _x; }
        set { _x = value; }
    }
    private int _y;
    public int Y
    {
        get { return _y; }
        set { _y = value; }
    }

    public Position()
    {
        _x = _y = 0;
    }

    public Position(int x, int y)
    {
        _x = x;
        _y = y;
    }

    public override string ToString()
    {
        return X + "-" + Y;
    }

}

public class Utils {

    public static float Direct(Position pos1, Position pos2)
    {
        float dy = pos2.Y - pos1.Y;
        float dx = pos2.X - pos1.X;
        float angle = Mathf.Atan2(dy, dx) * Mathf.Rad2Deg ;
        angle += Mathf.PI * Mathf.Rad2Deg / 2;
        return angle;
    }

    public static float Direct(Vector3 pos1, Vector3 pos2)
    {
        float dy = pos2.y - pos1.y;
        float dx = pos2.x - pos1.x;
        
        float angle = Mathf.Atan2(dy, dx) * Mathf.Rad2Deg;
        return angle;
    }

    public static float Distance(Position pos1, Position pos2)
    {
        int xDis = pos2.X - pos1.X;
        int yDis = pos2.Y - pos1.Y;
        return Mathf.Sqrt(xDis * xDis + yDis * yDis);
    }
}